package br.ucb.musicbay.album;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;


public class AlbumDataModel extends ListDataModel<Album> implements SelectableDataModel<Album>, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public AlbumDataModel(List<Album> list) {
		super(list);
	}
	
	@Override
	public Album getRowData(String rowKey) {
		@SuppressWarnings("unchecked")
		List<Album> lista = (List<Album>) getWrappedData();
		for (Album album : lista) {
			if(album.getIdAlbum().equals(Integer.parseInt(rowKey)))
				return album;
		}
		return null;
	}

	@Override
	public Object getRowKey(Album album) {
		return album.getIdAlbum();
	}

}
